package com.android.infantschool.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

/**
 * @author Administrator
 * @particulars 为了避免用户在广告栏位随意切换, 用父布局将其触摸事件进行拦截
 * @time 2019\4\1 0001 17:44
 * @class describe
 */
public class ForbidRelativeLayout extends RelativeLayout {

    public ForbidRelativeLayout(Context context) {
        super(context);
    }

    public ForbidRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        return super.dispatchTouchEvent(event);
    }

    /**
     * 添加事件拦截,以免用户在banner广告中随意切换广告
     *
     * @param event
     * @return true:拦截,false:不拦截
     */
    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        super.onInterceptTouchEvent(event);
        return true;
    }

    /**
     * 添加事件拦截,以免用户在banner广告中随意切换广告
     *
     * @param event
     * @return true:拦截,false:不拦截
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        super.onTouchEvent(event);
        return true;
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        super.onWindowFocusChanged(hasWindowFocus);
    }
}